<template>
  <div>
    <div class="item" v-for="(item,index) in list" :key="index">
      <div class="item-title">
        <span class="item-title-icon"></span>
        {{item.title}}
      </div>
      <!-- 递归组件：递归循环。如果item有children对象，把该对象再传给自己，组件的name就是组件的标签。搞不懂没关系，先记住它，慢慢理解 -->
      <div v-if="item.children" class="item-children">
        <detail-list :list="item.children"></detail-list>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "detailList",
  props: {
    list: Array
  },
  beforeCreate() {
    document.querySelector("body").setAttribute("style", "height:50rem;");
  },
  //销毁前清除
  beforeDestroy() {
    document.querySelector("body").removeAttribute("style");
  }
}; 
</script>

<style lang="less" scoped>
.item-title {
  line-height: 0.4rem;
  padding: 0.2rem;
  position: relative;
  border-bottom: 1px solid #ccc;
  .item-title-icon {
    display: inline-block;
    position: relative;
    top: 0.06rem;
    width: 0.36rem;
    height: 0.36rem;

    background: url(//s.qunarzz.com/piao/image/touch/sight/detail.png) 0 -0.45rem
      no-repeat;
    margin-right: 0.1rem;
    background-size: 0.4rem 3rem;
  }
}
.item-children {
  padding-left: 0.2rem;
}
</style>
